package main

import "local/datastructure/stack"

type Queue struct {
	s1 stack.Stack
	s2 stack.Stack
}

func New() Queue {
	return Queue{
		s1: stack.New(),
		s2: stack.New(),
	}
}

func (q *Queue) Push(e int) int {
	q.s1.Push(e)
}

func (q *Queue) Pop() int {
	if q.s1.IsEmpty() {
		q.trans()
	}

	return q.s2.Pop()
}

func (q *Queue) Peek() {
	if q.s1.IsEmpty() {
		q.trans()
	}
}

func (q *Queue) IsEmpty() bool {
	return q.s1.IsEmpty() && q.s2.IsEmpty()
}

func (q *Queue) trans() {
	for !q.s1.IsEmpty() {
		q.s2.Push(q.s1.Pop())
	}
}

func main() {

}
